/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package managedBean.TX.OutletManagement;

import session.TX.AreaSBRemote;
import java.util.List;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import session.TX.OutletSBRemote;
import managedBean.TX.CustomerIOTRPortal.FakeMainPortalMB;
import entity.OutletSeatArea;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.ViewScoped;
import javax.faces.event.ActionEvent;

/**
 *
 * @author Lu Xiaodi
 */
@ManagedBean (name="outletManagerIOTRManagedBean")
@ViewScoped
public class OutletManagerIOTRMB {

    @EJB
    private OutletSBRemote outletBean;
    @EJB
    private AreaSBRemote areaBean;
    @ManagedProperty(value = "#{TrackerOutletAdmin}")
    private TrackerManagedOutletMB trackerManagedOutletMB;
    private String stakeholderName;
    private Integer phoneNumber;
    private String noShowPenaltyString;
    private Integer bookingQuota;
    private String autoConfirmReservation;
    private String leadTime_DayString;
    private String bookingWindowString;
    private String statusMessage;
    
    /** Creates a new instance of OutletManagerIOTRMB */
    public OutletManagerIOTRMB() {
    }

    public void saveNewGeneralInfo(ActionEvent event) {
        final Boolean autoConfirm = Boolean.valueOf(autoConfirmReservation);
        final Integer leadTime_Day = Integer.valueOf(this.leadTime_DayString);
        final Integer bookingWindow = Integer.valueOf(this.bookingWindowString);
        final Double noShowPenalty = Double.valueOf(noShowPenaltyString);
        System.out.println(autoConfirm);
        System.out.println(leadTime_Day);
        System.out.println(bookingWindow);
        System.out.println(noShowPenalty);
        if (trackerManagedOutletMB.getOutletId() == null) {
            //throw login error
            return;
        }
        statusMessage = outletBean.updateGeneralInfo(trackerManagedOutletMB.getOutletId(), noShowPenalty, autoConfirm, leadTime_Day, bookingWindow);
    }

    public String getAutoConfirmReservation() {
        return autoConfirmReservation;
    }

    public void setAutoConfirmReservation(String autoConfirmReservation) {
        this.autoConfirmReservation = autoConfirmReservation;
    }

    public Integer getBookingQuota() {
        return bookingQuota;
    }

    public void setBookingQuota(Integer bookingQuota) {
        this.bookingQuota = bookingQuota;
    }

    public String getNoShowPenalty() {
        Double penalty = outletBean.getNoShowPenalty(trackerManagedOutletMB.getOutletId());
        if (penalty == null) {
            return null;
        }
        return penalty.toString();
    }

    public void setNoShowPenalty(String noShowPenalty) {
        this.noShowPenaltyString = noShowPenalty;
    }

    public Integer getPhoneNumber() {
        return phoneNumber;
    }

    public void setPhoneNumber(Integer phoneNumber) {
        this.phoneNumber = phoneNumber;
    }

    public String getStakeholderName() {
        return stakeholderName;
    }

    public void setStakeholderName(String stakeholderName) {
        this.stakeholderName = stakeholderName;
    }

    public String getLeadTime_Day() {
        Integer leadTime = outletBean.getLeadTime(trackerManagedOutletMB.getOutletId());
        if (leadTime == null) {
            return null;
        }
        return leadTime.toString();
    }

    public void setLeadTime_Day(String leadTime_Day) {
        this.leadTime_DayString = leadTime_Day;
    }

    public String getBookingWindow() {
        Integer bookingWindow = outletBean.getBookingWindow(trackerManagedOutletMB.getOutletId());
        if (bookingWindow == null) {
            return null;
        }
        return bookingWindow.toString();
    }

    public void setBookingWindow(String bookingWindow) {
        this.bookingWindowString = bookingWindow;
    }

    public String getStatusMessage() {
        return statusMessage;
    }

    public void setStatusMessage(String statusMessage) {
        this.statusMessage = statusMessage;
    }

    public List<OutletSeatArea> getAreas() {
        return areaBean.getAllAreas(trackerManagedOutletMB.getOutletId());
    }

    public TrackerManagedOutletMB gettrackerManagedOutletMB() {
        return trackerManagedOutletMB;
    }

    public void settrackerManagedOutletMB(TrackerManagedOutletMB trackerManagedOutletMB) {
        this.trackerManagedOutletMB = trackerManagedOutletMB;
    }

    public String getOutletName() {
        return trackerManagedOutletMB.getOutletName();
    }
}
